CFLAGS = -Wall -Wextra -Wconversion -O2 -static -mwindows
OBJECTS = main.o cv.o control.o thread.o ui.o options.o resource.o
LINK_OBJECTS = -lmingw32 -lopencv_imgproc231.dll -lopencv_core231.dll\
	       -lopencv_highgui231.dll -lgdi32 -lole32

aippt: $(OBJECTS)
	g++ $(CFLAGS) -Wl,-enable-auto-import -o aippt.exe $(OBJECTS) $(LINK_OBJECTS)

taiko: $(OBJECTS)
	g++ $(CFLAGS) -DEX_TAIKO -Wl,-enable-auto-import -o aippt_taiko.exe $(OBJECTS) $(LINK_OBJECTS)

$(OBJECTS): common.h options.h makefile

main.o: main.cpp ui.h cv.h thread.h
	g++ -c $(CFLAGS) -o main.o main.cpp

cv.o: cv.cpp cv.h
	g++ -c $(CFLAGS) -o cv.o cv.cpp

control.o: control.cpp control.h
	g++ -c $(CFLAGS) -o control.o control.cpp

ui.o: ui.cpp ui.h thread.h
	g++ -c $(CFLAGS) -o ui.o ui.cpp

options.o: options.cpp options.h
	g++ -c $(CFLAGS) -o options.o options.cpp

thread.o: thread.cpp thread.h cv.h
	g++ -c $(CFLAGS) -o thread.o thread.cpp

resource.o: resource.rc resource.h
	windres resource.rc resource.o -O coff

clean:
	rm aippt.exe
	rm $(OBJECTS)

.PHONY: aippt taiko clean
